Skip to content

Order signal-pad operations per process group across streams - #27

Open
kapilsh wants to merge 1 commit into
symmem/capture-checkfrom
symmem/stream-guard
Open

kapilsh wants to merge 1 commit into
symmem/capture-checkfrom
symmem/stream-guard

Conversation

@kapilsh

@kapilsh kapilsh commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Similar lines as PyTorch GroupStreamGuard ([symm_mem]: Add per-PG stream serialization for ops pytorch/pytorch#195947, symm_mem: Complete per-group stream serialization for NCCL and improve tests  pytorch/pytorch#199418).
  • Problem: two signal-pad operations of one group on different streams can use the signals of each other. For example, a barrier can finish before all ranks arrive.
  • group_stream_guard wraps barrier, put_signal and wait_signal.
  • For each (process group, device), the guard records an event after each launch. An operation on a different stream waits for that event first.
  • During graph capture, the record and the wait become graph edges. The guard tracks them separately from eager operations.
  • The guard keeps only a weak reference to each process group.
  • Difference from PyTorch: the guard also wraps put_signal and wait_signal of the NCCL backend. Both backends use the same kernels and signal pad.

Test plan

  • test_stream_order.py on 2x GB200: 2 passed.
  • The tests check the order through captured graph edges and cuStreamWaitValue32 gates, in one group and across groups.

@kapilsh
kapilsh added this pull request to stack #26 November 12, 2026 18:10
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 12, 2026
@kapilsh
kapilsh force-pushed the symmem/stream-guard branch from 93262ee to 0dd13e4 Compare November 16, 2026 15:26
@kapilsh
kapilsh removed this pull request from stack #26 November 16, 2026 15:28
@kapilsh
kapilsh added this pull request to stack #31 November 16, 2026 15:28
@kapilsh
kapilsh force-pushed the symmem/stream-guard branch 6 times, most recently from f7372bf to de08ec8 Compare November 19, 2026 19:26
@kapilsh
kapilsh removed this pull request from stack #31 November 20, 2026 02:41
@kapilsh
kapilsh force-pushed the symmem/stream-guard branch from de08ec8 to 717e79d Compare November 20, 2026 02:41
@kapilsh
kapilsh added this pull request to stack #34 November 20, 2026 02:41
@kapilsh
kapilsh force-pushed the symmem/stream-guard branch 2 times, most recently from d0343d2 to 7c1f3f1 Compare November 22, 2026 14:05
@kapilsh
kapilsh removed this pull request from stack #34 November 22, 2026 14:30
@kapilsh
kapilsh added this pull request to stack #41 November 22, 2026 14:30
@kapilsh
kapilsh force-pushed the symmem/stream-guard branch from 7c1f3f1 to 50db5e2 Compare November 26, 2026 11:32
Mirrors PyTorch's GroupStreamGuard (#195947, #199418). Two signal-pad
operations of one group running concurrently on different streams can
consume each other's signals, e.g. a barrier finishing before every rank
arrived.

group_stream_guard wraps barrier, put_signal and wait_signal. Per
(process group, device) it records an event after each launch; an
operation on a different stream waits on it first. Under graph capture
the record and wait become graph edges, tracked separately from eager
operations. State is keyed weakly by the process group.

Unlike torch, the NCCL backend's put_signal/wait_signal are guarded too:
here both backends share the same kernels and signal pad.

Tests check the ordering through captured graph edges and
cuStreamWaitValue32 gates, within a group and across groups.
@kapilsh
kapilsh force-pushed the symmem/stream-guard branch from 50db5e2 to 1ecfd41 Compare November 27, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant